<!DOCTYPE html><html><head><meta charset="UTF-8"><title>gitbook技术文档</title><style>body {padding: 50px;font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;}
a {color: #00B7FF;}</style><!--link(rel='stylesheet', href='/stylesheets/style.css')--><link rel="stylesheet" href="https://cdn.bootcss.com/twitter-bootstrap/3.4.0/css/bootstrap.min.css"><script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script><script src="https://cdn.bootcss.com/twitter-bootstrap/3.4.0/js/bootstrap.min.js"></script><!--script(src='/javascripts/style.js')--><script>$(function () {$('table').addClass('table table-striped table-bordered table-hover table-condensed');});</script></head><body><div class="container table-bordered"><h1 id="gitbook-"><code>GitBook</code> 安装</h1>
<h2 id="gitbook-"><a href="https://www.gitbook.com/?t=1">GItBook官网</a></h2>
<h2 id="gitbook-"><a href="https://docs.gitbook.com/">GitBook文档</a></h2>
<h2 id="-"><a href="https://atom.io/">个人推荐编辑器下载</a></h2>
<h2 id="-node-js">安装 <code>node.js</code></h2>
<p>gitbook 是基于 Node.js的命令行工具，<a href="https://nodejs.org/en/">下载地址</a></p>
<p>检测是否安装成功：</p>
<pre><code>$ node -v
10.14.2</code></pre><h2 id="-gitbook">安装 <code>GitBook</code></h2>
<pre><code>$ npm install -g gitbook-cli</code></pre><p>检测是否安装成功：</p>
<pre><code>$ gitbook -V (大写的V)
CLI version: 2.3.2
GitBook version: 3.2.3</code></pre><p>其他命令 请参考： <code>gitbook help</code> 及 <code>gitbook --help</code></p>
<h2 id="-npm-uninstall-g-gitbook">卸载 <code>npm uninstall -g gitbook</code></h2>
<h1 id="-">创建书籍</h1>
<pre><code>$ gitbook init bookname --log=debug
warn: no summary file in this book
info: create README.md
info: create SUMMARY.md
info: initialization is finished</code></pre><h1 id="-book-json">配置文件 <code>book.json</code></h1>
<p>在书籍目录 <code>bookname</code> 中，新建一个 <code>book.json</code> 文件，可以配置网站信息、加载的插件等相关内容。事例如下：</p>
<p><a href="https://plugins.gitbook.com/">GitBook插件下载地址</a></p>
<pre><code>{
    &quot;title&quot;: &quot;标题&quot;,
    &quot;description&quot;: &quot;描述...&quot;,
    &quot;author&quot;: &quot;Mr.Zhang&quot;,
    &quot;generator&quot;: &quot;GitBook&quot;,
    &quot;language&quot;: &quot;zh-hans&quot;,
    &quot;direction&quot;: &quot;ltr&quot;,
    &quot;plugins&quot;: [
        &quot;-sharing&quot;,
        &quot;-search&quot;,
        &quot;-lunr&quot;,
        &quot;expandable-chapters-small&quot;
    ],
    &quot;pluginsConfig&quot;: {},
    &quot;styles&quot;: {
        &quot;website&quot;: &quot;styles/style.css&quot;,
        &quot;ebook&quot;: &quot;styles/ebook.css&quot;,
        &quot;pdf&quot;: &quot;styles/pdf.css&quot;,
        &quot;mobi&quot;: &quot;styles/mobi.css&quot;,
        &quot;epub&quot;: &quot;styles/epub.css&quot;
    },
        &quot;structure&quot;: {
            &quot;readme&quot;: &quot;README.md&quot;,
            &quot;summary&quot;: &quot;SUMMARY.md&quot;,
            &quot;glossary&quot;: &quot;GLOSSARY.md&quot;,
            &quot;languages&quot;: &quot;LANGS.md&quot;,
        },
    &quot;links&quot;: {
        &quot;gitbook&quot;: false
    }
}</code></pre><p>说明：</p>
<ul>
<li>plugins: 配置插件，<code>-</code> 表示去掉此插件</li>
<li>styles： 定义自己的样式文件</li>
<li>....</li>
</ul>
<h1 id="-">安装插件</h1>
<pre><code>$ npm install xxx
或 在 book.json 中 plugins 添加好相关插件后，执行
$ gitbook install</code></pre><h2 id="-">默认插件</h2>
<ol>
<li>highlight 语法高亮插件</li>
<li>search 搜索框插件</li>
<li>sharing 分享插件</li>
<li>fontsettings 字体插件</li>
<li>livereload 动态加载插件，主要在 <code>gitbook serve</code> 时进行修改文件，自动加载时使用</li>
</ol>
<p>如果需要去除自带插件，可如下配置：</p>
<pre><code>&quot;plugins&quot;: [
    &quot;-sharing&quot;,
    &quot;-search&quot;,
    &quot;-lunr&quot;,
        &quot;anchor-navigation@git+https://gitee.com/who7708/gitbook-plugin-anchor-navigation&quot;,
    &quot;expandable-chapters-small&quot;
],</code></pre><h1 id="-">生成书籍</h1>
<h2 id="-">生成网站</h2>
<pre><code>$ gitbook build &lt;bookpath&gt;</code></pre><h2 id="-">生成预览</h2>
<pre><code>$ gitbook serve .</code></pre><p>默认是4000端口</p>
<h2 id="-pdf">生成pdf</h2>
<pre><code>$ gitbook pdf &lt;bookpath&gt;</code></pre><p>生成pdf时，需要Calicre依赖，<a href="https://calibre-ebook.com/">下载地址及安装</a></p>
<p>其他生成命令请参考 gitbook 帮助</p>
<h1 id="-">相关插件</h1>
<ol>
<li><a href="https://gitee.com/who7708/gitbook-plugin-qrcode-list">qrcode-list</a></li>
<li><a href="https://gitee.com/who7708/gitbook-plugin-expandable-chapters">expandable-chapters</a></li>
<li><a href="https://gitee.com/who7708/gitbook-plugin-anchor-navigation-ex">anchor-navigation-ex</a> 包含4，5两种</li>
<li><a href="https://gitee.com/who7708/gitbook-plugin-navigator">navigator</a></li>
<li><a href="https://gitee.com/who7708/gitbook-plugin-anchor-navigation">anchor-navigation</a></li>
<li><a href="https://gitee.com/who7708/theme-official">theme-official 官方</a></li>
<li>theme-default 默认主题</li>
<li>splitter 左侧菜单栏插件</li>
<li><a href="https://gitee.com/who7708/gitbook-plugin-tbfed-pagefooter">tbfed-pagefooter 页脚插件</a></li>
<li>favicon 自定义图标</li>
<li>donate 打赏插件</li>
</ol>
<p><a href="https://blog.csdn.net/qq_37149933/article/details/64170653">常用插件地址</a></p>
</div></body></html>